﻿
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using Utils;
using PanasonicWarranty.DAL;
namespace PanasonicWarranty.Business
{
    public partial class SmsStatus
    {
    	#region public properties
		[Required(ErrorMessage="Status Required")]
		public string Status { get; set; }
		public string StatusName { get; set; }
		public int? OrderID { get; set; }
		#endregion

		#region constructor
		public SmsStatus(){ }

		public SmsStatus(IDataReader rd)
		{
			this.Status = rd["Status"].ToString();
			this.StatusName = rd["StatusName"].ToString();
			this.OrderID = rd["OrderID"].Equals(DBNull.Value) ? (int?)null : (int)rd["OrderID"];
		}
		#endregion

		#region private method
        private bool Create()
        {
            return DBSmsStatus.Create(Status, StatusName, OrderID);
        }

        private bool Update()
        {
            return DBSmsStatus.Update(Status, StatusName, OrderID);
        }
		#endregion

		#region public method
		public bool Save()
		{
            if(Status != string.Empty)
            {
                return Update();
            }
            else
            {
                return Create();
            }
		}
		#endregion

		#region static method
        public static bool Delete(string Status)
        {
            return DBSmsStatus.Delete(Status);
        }

        public static List<SmsStatus> GetAll()
        {
            return ObjectClass.CreateList<SmsStatus>(DBSmsStatus.GetAll());
        }

        public static SmsStatus GetByKey(string Status)
        {
            return ObjectClass.CreateInstance<SmsStatus>(DBSmsStatus.GetByKey(Status));
        }

        public static List<SmsStatus> GetByTop(string top, string where, string order)
        {
            return ObjectClass.CreateList<SmsStatus>(DBSmsStatus.GetByTop(top, where, order));
        }
		#endregion
	}
}
